package com.diaohw.module.system.mapper;

import cn.hutool.core.util.StrUtil;
import com.diaohw.module.system.obj.entity.Permission;
import com.diaohw.module.system.obj.query.PermissionQuery;
import com.diaohw.module.system.obj.tables.PermissionDef;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
/**
 * 系统权限 映射层。
 *
 * @author D-Hw
 * @since 2024-11-15 18:22:15
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {


    static QueryWrapper createWrapper(PermissionQuery query){
       QueryWrapper wrapper = QueryWrapper.create();
       wrapper.and(PermissionDef.PERMISSION.MENU_ID.eq(query.getMenuId()).when(StrUtil.isNotBlank(query.getMenuId())));
       wrapper.and(PermissionDef.PERMISSION.PERMISSION_CODE.eq(query.getPermissionCode()).when(StrUtil.isNotBlank(query.getPermissionCode())));
       wrapper.and(PermissionDef.PERMISSION.PERMISSION_NAME.eq(query.getPermissionName()).when(StrUtil.isNotBlank(query.getPermissionName())));
       return wrapper;
   }
}
